package test.twlGDX;

import twl.global.libgdx.GlobalTWL;

import com.badlogic.gdx.Files.FileType;
import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;

public class TryTWLGDX extends Game{
	
	private GlobalTWL twl;
	private SpriteBatch spriteBatch;
	
	public void create() {
		spriteBatch = new SpriteBatch();
		
		twl = new GlobalTWL(spriteBatch, "test/twlGDX/NewFile.xml", FileType.Internal);
		
		twl.getGlobalGUI().addGlobalEventListener(new RootPane());
		
		Gdx.input.setInputProcessor(twl);
	}
	
	@Override
	public void render() {
		twl.render();
 
		try {
			Thread.sleep(16); // ~60FPS
		} catch (InterruptedException e) {
		}
	}
 
	@Override
	public void dispose() {
		spriteBatch.dispose();
		twl.dispose();
	}
	
	public static void main(String args[]) {
		LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
		config.vSyncEnabled = true;
		config.samples = 4;
		config.title = "Protect Castle";
		config.width = 800;
		config.height = 600;
		config.depth = 0; //at slick this is done automatically, This save some amount of VRAM		
		config.fullscreen = false;
		
		new LwjglApplication(new TryTWLGDX(), config);
	}

}
